//格式化当前时间
const formatTime = (obj = {}) => {
	const {
		date,
		isHours = true,
		division = '-'
	} = obj
	const time = date ? new Date(date) : new Date()
	const year = time.getFullYear();
	const month = (time.getMonth() + 1).toString().padStart(2, '0');
	const day = time.getDate().toString().padStart(2, '0');
	const hours = time.getHours().toString().padStart(2, '0');
	const minutes = time.getMinutes().toString().padStart(2, '0');
	const seconds = time.getSeconds().toString().padStart(2, '0');
	return isHours ? `${year}${division}${month}${division}${day} ${hours}:${minutes}:${seconds}` :
		`${year}${division}${month}${division}${day}`;
}

export default formatTime